// pages/SocialSecurityCard/SocialSecurity_all/SocialSecurity_all.js
import {
  queryTempFunctionCode
} from '../../../utils/login'
import {saveMatter} from '../../../utils/my'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    menuInfo: {},
    str: [{
        id: '1',
        name: '职业技能等级认定证书查询',
        src: '/images/more/rcrs1.png',
        code: 'RCRS_0073',
        icon:'rsrc1'
      },
      {
        id: '2',
        name: '依据档案记载出具相关证明',
        src: '/images/more/rcrs2.png',
        code: 'RCRS_0005',
        icon:'rsrc2'
      },
      {
        id: '3',
        name: '档案转出',
        src: '/images/more/rcrs3.png',
        code: 'RCRS_0004',
        icon:'rsrc3'
      },
      {
        id: '4',
        name: '流动人员人事档案查询',
        src: '/images/more/rcrs4.png',
        code: 'RCRS_0044',
        icon:'rsrc4'
      },
      {
        id: '5',
        name: '流动人员人事档案接收',
        src: '/images/more/rcrs5.png',
        url: '/pages/SocialSecurityCard/FormList/FormList',
        code: 'RCRS_0003',
        icon:'rsrc5'
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    //设置头部字体与导航栏对齐
    const top = getApp()
    this.setData({
      menuInfo: top.geibartop.menuInfo
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
  //跳转页面
  jumpPage(e) {
    const code = e.currentTarget.dataset.code;
    const name = e.currentTarget.dataset.name;
    if(code){
      queryTempFunctionCode(code).then(res => {
        saveMatter(name) //保存事项
        wx.navigateTo({
          url: '/pages/web_h5/web_h5?url=' + encodeURIComponent(res.data)
        })
      })
    }else{
      wx.showToast({
        title: '功能代码错误！',
        icon: 'error',
        duration: 2000
      })
    }
    // console.log(e.currentTarget.dataset);
    // wx.navigateTo({
    //   url: e.currentTarget.dataset.url
    // })
  },
  //返回上一级
  backPage() {
    wx.navigateBack({
      delta: 1
    });
  },
})